package guda.mrpc.core.transport;

import guda.mrpc.core.codec.MsgHeader;
import io.netty.buffer.ByteBuf;
import io.netty.buffer.Unpooled;

/**
 * Created by well on 17/6/3.
 */
public class Hearbeat {

    private static final ByteBuf HEARTBEAT_BUF;

    static {
        ByteBuf buf = Unpooled.buffer(MsgHeader.HEAD_LENGTH);
        buf.writeShort(MsgHeader.MAGIC);
        buf.writeShort(MsgHeader.HEARTBEAT);
        buf.writeInt(0);
        HEARTBEAT_BUF = Unpooled.unreleasableBuffer(buf).asReadOnly();
    }


    public static ByteBuf heartbeatContent() {
        return HEARTBEAT_BUF.duplicate();
    }

    public static class NullHearbeat{
       public static NullHearbeat instance =new NullHearbeat();
    }
}
